'''
@Author: your name
@Date: 2020-03-21 21:49:23
@LastEditTime: 2020-03-21 22:18:53
@LastEditors: Please set LastEditors
@Description: In User Settings Edit
@FilePath: \giee\learn_python\爬虫\爬虫基础\练习项目\pyquery的使用.py
'''
import requests
from fake_useragent import UserAgent
from pyquery import PyQuery as pq
import time

def main():

    url = "https://www.xicidaili.com/"

    headers = {
        "User-Agent": UserAgent().random
    }

    response = requests.get(url, headers=headers)
    
    doc = pq(response.text)
    trs = doc('#ip_list tr')

    for num in range(1, len()):
        ip = trs[num].eq(1).find('td').eq(1).text()
        port = trs[num].eq(1).find('td').eq(2).text()
        type = trs[num].eq(1).find('td').eq(5).text()
        print(ip, ":", port, ":", type)



if __name__ == "__main__":
    main()